package zuoye3;
import java.util.Comparator;
import java.util.Comparator;
import java.util.List;
public class ScoreAndAgeComparator implements Comparator<Student> {
    @Override
    public int compare(Student o1, Student o2) {
        //首先按照成绩降序排序，如果成绩相等，再在成绩排序的基础上按照年龄升序排序。
        int result = o2.getScore().compareTo(o1.getScore());
        if(result == 0){
            return o1.getAge().compareTo(o2.getAge());
        }
        return result;
    }
}

